#ifndef USART_H
#define USART_H

#include <QDebug>
#include <fcntl.h>
#include <unistd.h>
#include <termios.h>
#include <sys/types.h>
#include <sys/select.h>
#include <stdlib.h>
#include <unistd.h>
#include <netdb.h>
#include <string.h>
#include <errno.h>
#include <time.h>
#include <QThread>
#include <QTimer>

#define DEV_PATH   "/dev/ttySAC2" //打开串口

//rfid 卡类
class Rfid : public QThread
{
    Q_OBJECT
public:
    static Rfid *Get()
    {
        static Rfid r;
        return &r;
    }

    Rfid();
    void run()override;

    int serial = 3;
    unsigned long cardid = 0;
    struct timeval timeout;
    int cmd = 1;
    unsigned char CalBCC(unsigned char *buf, int n);
    int PiccRequest(int fd);
    int PiccAnticoll(int fd);
    void init_tty(int fd);

    void sendData(int data);
signals:
    void sendCardId(unsigned long);
};


#endif // USART_H
